package com.cloud.freeflow.api.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cloud.freeflow.api.entity.ProcPart;
import com.cloud.freeflow.api.service.ProcPartService;
import com.cloud.freeflow.common.result.Quokka;

@RestController
@RequestMapping("freeflow/api/procpart")
public class ProcPartController {

	@Autowired
	private ProcPartService procPartService;
	
	@RequestMapping("/list")
	public Quokka listProcParts(long id){
		return new Quokka("data", procPartService.listProcParts(id));
	}
	
	@RequestMapping("/add")
	public Quokka addParts(@RequestBody List<ProcPart> procParts){
		return new Quokka("data", procPartService.addParts(procParts));
	}
	
	@RequestMapping("/delete")
	public Quokka deleteParts(ProcPart part){
		return new Quokka("data", procPartService.deleteParts(part));
	}
	
	@RequestMapping("listactparts")
	public Quokka listActParts(Long actDefId) {
		return new Quokka(true, procPartService.listActParts(actDefId));
	}

	@RequestMapping("saveactparts")
	public Quokka saveActParts(Long actDefId, String partIds) {
		procPartService.saveActParts(actDefId, partIds);
		return new Quokka(true);
	}
	
}
